package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.annotation.AutoFill;
import com.itheima.enumeration.OperationType;
import com.itheima.pojo.*;
import org.apache.ibatis.annotations.*;
import org.springframework.expression.Operation;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {


    /**
     * 分页查询学员信息
     * @return
     */
    Page<Student> selectPage(StudentQueryString stringQueryParam);

    /**
     * 根据班级id查询班级信息
     * @param
     * @return
     */
    @Select("select count(*) from student where clazz_id=#{id}")
    Integer existsWithClazzId(Integer clazzID);


    /**
     * 批量删除学员信息
     * @param ids
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 添加学员信息
     * @param student
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Student student);

    /**
     * 根据id查询学员信息
     */
    Student selectById(Integer id);

    /**
     * 修改学生信息
     * @param student
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateById(Student student);

    /**
     * 根据学员id查询学员的学历信息
     */
    @MapKey("name")
    List<Map<String, Object>> countStudentDegreeData();
    /**
     * 班级人数统计
     */
    @MapKey("name")
    List<Map<String, Object>> countClazzData();
}
